import { FC } from "react";
import type { FormProps } from "antd";
import { Button, Form, Input, message } from "antd";

type FieldType = {
  title?: string;
  color?: string;
};

const onFinish: FormProps<FieldType>["onFinish"] = (values) => {
//   httpPost("/knowledge/submitKnowledge", values);
  message.success("新增题目成功");
};

const onFinishFailed: FormProps<FieldType>["onFinishFailed"] = (errorInfo) => {
  console.log("Failed:", errorInfo);
  message.error("新增题目失败"+errorInfo);
};

const onChange = (value: string) => {
    console.log(value);
};
  
const onSearch = (value: string) => {
    console.log(value);
};

const SubmitBlank: FC = () => {


  return (
    <>
      <Form
        name="basic"
        labelCol={{ span: 8 }}
        wrapperCol={{ span: 16 }}
        style={{ maxWidth: 600, marginTop: 40 }}
        initialValues={{ remember: true }}
        onFinish={onFinish}
        onFinishFailed={onFinishFailed}
        autoComplete="off"
      >
        <Form.Item<FieldType>
          label="题目"
          name="title"
          rules={[{ required: true, message: "请输入题目!" }]}
        >
          <Input />
        </Form.Item>

        <Form.Item<FieldType>
          label="答案"
          name="color"
          rules={[{ required: true, message: "请输入答案!" }]}
        >
          <Input />
        </Form.Item>

        <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
          <Button type="primary" htmlType="submit">
            新增题目
          </Button>
        </Form.Item>
      </Form>
    </>
  );
};

export default SubmitBlank;
